    function openService(){
        var window1 = document.getElementById('textList');
        window1.style.display = 'block';
    }
    function closeWindow(){
    var window1 = document.getElementById('textList');
    window1.style.display = 'none';
}
    function isCode(){
    var code = document.querySelector('.codeMa');
    var c = getQueryVariable('c');
    if (c) {
    code.value=c
}
}
    function ailpay() {
        let code = $('#code').val().trim()||"";
        let str = $('#mobile').val().trim();
        if (str) {
            var myreg = /^1([3456789])\d{9}$/;
            if (!myreg.test(str)) {
                alert('手机号格式不正确');
            } else {
                const checkbox = document.getElementById('agree');
                if(checkbox.checked){
                var codeDiv = document.querySelector('.model');
                if (codeDiv.style.display !== 'none') {
                    codeDiv.style.display = 'none';
                } else {
                    codeDiv.style.display = 'block';
                }
                let phoneNumEnc = window.btoa(str);
                let isWechat = /MicroMessenger/i.test(navigator.userAgent);
                let payType = isWechat ? 'A' : ' C';
                // let payType =  'B';
                let g = getQueryVariable('g') || null;
                var postData = {
                    payType: payType,
                    phoneNumEnc: phoneNumEnc,
                    code:code
                };
                if (g) {
                    postData.g = g;
                }
                 $.ajax({
                    type: 'POST',
                    url: httpUrl+'/api/v1/open/order',
                    contentType: 'application/json',
                    data: JSON.stringify(postData),
                    success: function(result) {
                        if(result.code=='10000'){
                            codeDiv.style.display = 'none';
                            if (window.parent === window) {
                                if (isWechat && payTypeInfo.in === 'B') {
                                    _AP.pay(result.data)
                                } else {
                                    location.href = result.data;
                                }
                            } else {
                                const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
                                let token = getQueryVariable('jy')
                                if (isWechat && isIOS && token) {
                                    window.parent.postMessage(
                                        {action: 'NAVIGATE', url: result.data},
                                        '*' // 安全建议：替换为具体的父级 origin
                                    );
                                } else {
                                    location.href = result.data;
                                }

                            }
                        }else{
                            codeDiv.style.display = 'none';
                            setTimeout(()=>{
                                alert(result.msg)
                            },50)
                        }

                    },
                    error: function(xhr, status, error) {
                        codeDiv.style.display = 'none';
                        setTimeout(()=>{
                            alert('支付失败，请稍后再试。');
                        },50)

                    }
                });
            } else{
                alert('请先勾选下方服务条款');
            }
        }

    } else {
            alert('请先输入手机号');
    }
}

    function toGet() {
    var targetUrl = 'lq.html';
    var g = getQueryVariable('g');
    if (g) {
    targetUrl += '?g=' + encodeURIComponent(g);
}
    window.location.href = targetUrl;
}
    function calculateTimeToNextTimeSlot() {
    const now = new Date();
    const currentMinutes = now.getMinutes();
    const currentSeconds = now.getSeconds();
    let targetMinutes, targetSeconds;

    // 判断是倒计时到下一个整点（00分钟）还是倒计时到下一个半小时（30分钟）
    if (currentMinutes < 30) {
    // 如果当前时间小于30分钟，目标时间是下一个小时的00分钟
    targetMinutes = 59 - currentMinutes;
    targetSeconds = 59 - currentSeconds;
} else {
    // 如果当前时间大于等于30分钟，目标时间是下一个半小时的30分钟
    targetMinutes = 59 - currentMinutes + 30; // 30分钟加上剩余分钟
    targetSeconds = 59 - currentSeconds;
}

    return {
    minutes: targetMinutes,
    seconds: targetSeconds
};
}
    function formatTime(value) {
    return value < 10 ? '0' + value : value;
}
    function updateCountdown() {
    const timeToNextSlot = calculateTimeToNextTimeSlot();
    let minutes = timeToNextSlot.minutes;
    let seconds = timeToNextSlot.seconds;
    let countdown = 9; // 毫秒倒计时的开始数字，从9开始
    const minuteElement = document.getElementById('m');
    const secondElement = document.getElementById('s');
    const countdownElement = document.getElementById('ms'); // 用于显示倒数
    // 初始更新
    minuteElement.textContent = formatTime(minutes);
    secondElement.textContent = formatTime(seconds);
    countdownElement.textContent = countdown;

    // 倒计时逻辑
    const interval = setInterval(function () {
    // 每个秒内的倒数从9到0
    if (countdown > 0) {
    countdown--; // 每秒减少1
} else {
    // 当倒计时结束时，进入下一个秒
    if (seconds > 0) {
    seconds--;
    countdown = 9; // 重新开始从9倒数
} else {
    if (minutes > 0) {
    minutes--;
    seconds = 59;
    countdown = 9; // 重新开始从9倒数
}
}
}

    // 更新页面
    minuteElement.textContent = formatTime(minutes);
    secondElement.textContent = formatTime(seconds);
    countdownElement.textContent = countdown;

    // 如果倒计时结束，停止定时器
    if (minutes === 0 && seconds === 0 && countdown === 0) {
    clearInterval(interval);
    minuteElement.textContent = '00';
    secondElement.textContent = '00';
    countdownElement.textContent = '00';
}
}, 100); // 每100毫秒更新一次
}
    function getPhoneList(){
    $.ajax({
    type: 'GET',
    url: httpUrl+'/api/v1/open/searchPhone',
    success: function(data) {
    if(data.code=='10000'){
    var phoneList =data.data;
    if(phoneList.length){
    for (let i = 0; i < phoneList.length; i++) {
    var item = phoneList[i];
    var scrollText = document.getElementById("scrollText");
    var span = document.createElement("span");
    span.textContent = item+' 充值成功,获得200元话费';
    scrollText.appendChild(span);
}
}
}
},
    error: function(xhr, status, error) {
}
});

}
    // 统计
    function statistics(){
    $.ajax({
    type: 'GET',
    url: httpUrl+'/api/v1/open/statisticsRequests',
    success: function(data) {

},
    error: function(xhr, status, error) {
}
});

}

    // 初始化倒计时
    updateCountdown();
    // 成功充值列表
    getPhoneList()
    // 是否有邀请码
    isCode()
    // 统计次数
    statistics()
